import Mock from 'mockjs'
import { builder, getBody } from './util.js'

const username = ['123']
const password = ['123456']

const login = (options) => {
	const body = getBody(options)
	
	if(!username.includes(body.username) || !password.includes(body.password)) {
		return builder({isLogin: true}, '账号密码错误', 401)
	}
	
	return builder({}, '', 1, {'access-token': '4291d7da9005377ec9aec4a71ea837f'})
}

const logout = () => {
	return builder({}, '注销成功', 1)
}

Mock.mock('http://localhost/api/login', 'post', login)
Mock.mock('http://localhost/api/logout', 'get', logout)